﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using MvcCarConsume.Domain.Entites;
using MvcContrib.Pagination;

namespace MvcCarConsume.WebUI
{

    public class AdminViewInCars
    {
        public int CarId { get; set; }
        public string CarName { get; set; }
        public int BrandId { get; set; }
        public int TypeId { get; set; }
        public int Count { get; set; }
        public decimal Price { get; set; }
        public string Description { get; set; }
    }



    public class AdminViewAddCars
    {
        public string CarName { get; set; }
        public int BrandId { get; set; }
        public int TypeId { get; set; }
        public int Count { get; set; }
        public decimal Price { get; set; }
        public string Discription { get; set; }
    }

    public class VMAdminViewCars
    {
        private static int pagesize = 5;
        public int currentpage;
        public AdminViewAddCars car { get; set; }
        public IPagination<AdminViewInCars> Cars { get; set; }
        private List<AdminViewInCars> internallist = new List<AdminViewInCars>();
        public void LoadCars(IEnumerable<Car> cars , int page)
        {
            currentpage = page;
            if (cars != null)
            {
                foreach (var car in cars)
                    internallist.Add(new AdminViewInCars
                    {
                        CarId = car.CarId,
                        CarName = car.CarName,
                        BrandId = car.BrandId,
                        TypeId = car.TypeId,
                        Count = car.Count,
                        Price = car.Price,
                        Description = car.Description
                    });
                Cars = new LazyPagination<AdminViewInCars>(internallist.AsQueryable(), /*((currentpage-1)*pagesize >= internallist.Count) ? 1 : */page, pagesize);
            }
        }
    }
}